<template>
  <div v-loading="loading" style="position: relative; height: 100%">
    <div
      style="background-color: #fff; padding: 16px; text-align: left"
      v-if="!loading"
    >
      <div>转运单号：{{ transfer_no }}</div>
      <div style="font-size: 12px; color: #999; margin-top: 8px">
        <span> 提交时间：{{ baseData.ctime }}</span>
         <span style="margin-left: 40px">
          用户信息：
           {{ userData?.user_nick }}({{ userData?.id}})
          </span
        >
        <span style="margin-left: 40px">
          订单状态：{{
            getLable(transferStateOptions, baseData.transfer_state)
          }}</span
        >
        <span style="margin-left: 40px">
          运输方式：{{ getLable(modeOptions, baseData.transfer_mode) }}</span
        >
        <span style="margin-left: 40px">
          订单金额：<span style="font-size:24px; color: #f56c6c; font-weight: bold;">￥{{ baseData.transfer_price }}</span><span style="font-size: 14px; color: #f56c6c; font-weight: bold" >（包含附加费用：￥{{ baseData.transfer_other }}）</span>
        </span>
      </div>
    </div>
    <el-tabs
      v-model="activeName"
      class="demo-tabs"
      @tab-click="handleClick"
      style="background-color: #fff; margin-top: 16px; padding: 16px;"
      
    >
  
      <el-tab-pane label="订单信息" name="third">

        <el-divider content-position="left">基础信息</el-divider>
        
        <el-descriptions :column="3" size="defalut" border>
          <el-descriptions-item label="柜号">
            {{ baseData.transfer_cabinet_number  }}
          </el-descriptions-item>
            <el-descriptions-item label="最低消费">
            {{ costData.quotation_config?.quotation_min }}
          </el-descriptions-item>
             <el-descriptions-item label="计费重量">
            {{ costData.total_weight_cost }}
          </el-descriptions-item>
          <el-descriptions-item label="计费体积">
            {{ costData.total_volume_cost }}
          </el-descriptions-item>
          <el-descriptions-item label="计费件数">
            {{ costData.total_piece }}
          </el-descriptions-item>
          
          <!-- <el-descriptions-item label="订单状态">
            {{ getLable(transferStateOptions, baseData.transfer_state) }}
          </el-descriptions-item>
           <el-descriptions-item label="计费重量">
            {{ costData.total_weight_cost }}
          </el-descriptions-item>
          <el-descriptions-item label="计费体积">
            {{ costData.total_volume_cost }}
          </el-descriptions-item>
          <el-descriptions-item label="计费件数">
            {{ costData.total_piece }}
          </el-descriptions-item>
         
          <el-descriptions-item label="最低消费">
            {{ costData.quotation_config?.quotation_min }}
          </el-descriptions-item>
          <el-descriptions-item label="运输方式">
            {{ getLable(modeOptions, baseData.transfer_mode) }}
          </el-descriptions-item> -->
         
        </el-descriptions>
        
        <el-divider content-position="left">出库信息</el-divider>
        <el-descriptions :column="3" size="defalut" border v-if="!loading">
          <el-descriptions-item label="出库单号">
            {{ baseData.transfer_outbound_no }}
          </el-descriptions-item>
          <el-descriptions-item label="出库时间">
            {{ baseData.transfer_outbound_time ? baseData.transfer_outbound_time : '-' }}
          </el-descriptions-item>

          <el-descriptions-item label="出库人员">
            {{ baseData.transfer_outbound_manage_name }}
          </el-descriptions-item>
          <el-descriptions-item label="出库图片">
           <template  v-if="baseData.transfer_outbound_images?.length">

             <el-image
             v-for="(item, index) in baseData.transfer_outbound_images"
             :key="index"
              style="width: 100px; height: 100px"
              :src="$imageBaseUrl + item"
              :zoom-rate="1.2"
              :max-scale="7"
              :min-scale="0.2"
              :preview-src-list="[
                $imageBaseUrl + item,
              ]"
              :initial-index="0"
              fit="cover"
             
            />
           </template>
           
          </el-descriptions-item>
        </el-descriptions>
         <el-divider content-position="left">支付信息</el-divider>
        <el-descriptions :column="2" size="defalut" border v-if="baseData.pay_state == '2'">
            <el-descriptions-item label="支付单号">
              {{ payData.pay_no }}
            </el-descriptions-item>
            <el-descriptions-item label="支付方式">
            {{ payData.pay_type == 'wechat' ? '微信支付': '转账截图' }}
            </el-descriptions-item>
            <el-descriptions-item label="订单状态">
              支付成功
            </el-descriptions-item>
            <el-descriptions-item label="支付金额">
              {{ payData.pay_total }}
            </el-descriptions-item>
              <el-descriptions-item label="转账截图" v-if="payData.pay_type != 'wechat'">
            <el-image
                style="width: 100px; height: 100px"
                :src="$imageBaseUrl + baseData.transfer_audit_image[0]"
                :zoom-rate="1.2"
                :max-scale="7"
                :min-scale="0.2"
                :preview-src-list="[
                  $imageBaseUrl + baseData.transfer_audit_image[0],
                ]"
                :initial-index="0"
                fit="cover"
                v-if="baseData.transfer_audit_image?.length"
                ></el-image>
            </el-descriptions-item>
        </el-descriptions>
        <el-descriptions :column="2" size="defalut" border v-else>
          <el-descriptions-item label="订单状态">
             {{ getLable(payStateOptions,baseData.pay_state)}}
          </el-descriptions-item>
        </el-descriptions>
             <el-divider content-position="left" v-if="baseData.delivery_time"
          >派送信息</el-divider>
        <el-descriptions
          :column="2"
          size="defalut"
          border
          v-if="!loading && baseData.delivery_time"
        >
          <el-descriptions-item label="派送时间">
            {{ baseData.delivery_time ? baseData.delivery_time : "-" }}
          </el-descriptions-item>
          <el-descriptions-item
            label="查询网址"
            v-if="baseData.delivery_type == 'express'"
          >
            
            <a :href="baseData.delivery_web" target="_blank">{{ baseData.delivery_web }}</a>
          </el-descriptions-item>
          <el-descriptions-item label="派送方式">
            {{ getLable(dispatchStatus, baseData.delivery_type) }}
          </el-descriptions-item>
          <el-descriptions-item label="派送备注">
            {{ baseData.delivery_remark }}
          </el-descriptions-item>
          <el-descriptions-item label="派送图片">
            <template v-if="baseData.delivery_images?.length">
              <el-image
                v-for="(item, index) in baseData.delivery_images"
                :key="index"
                style="width: 100px; height: 100px"
                :src="$imageBaseUrl + item"
                :zoom-rate="1.2"
                :max-scale="7"
                :min-scale="0.2"
                :preview-src-list="[$imageBaseUrl + item]"
                :initial-index="0"
                fit="cover"
              />
            </template>
          </el-descriptions-item>
        </el-descriptions>
       
      </el-tab-pane>
        <el-tab-pane label="反馈信息" name="seven">
              <el-divider content-position="left">反馈信息</el-divider>
        <div>
          <el-table
            :data="costData.order_plan_list"
            show-summary
            :summary-method="getSummaries"
            border
            class="table-box"
            v-if="!loading"
          >
            <el-table-column prop="charging" label="计费线路">
              <template v-slot="scope">
                {{ getCost(scope.row) }}
              </template>
            </el-table-column>
            <el-table-column prop="charging" label="计费方式">
              <template v-slot="scope">
                {{ charging[scope.row.charging] }}
              </template>
            </el-table-column>
            <el-table-column prop="charging" label="抛重系数">
              <template v-slot="scope">
                {{ scope.row.quotation_throwing_weight }}
              </template>
            </el-table-column>
            <el-table-column prop="charging" label="体积重量">
              <template v-slot="scope">
                {{
                  scope.row.charging == "weight"
                    ? scope.row.throwing_weight
                    :  (scope.row.throwing_weight + "（不计费）")
                }}
              </template>
            </el-table-column>
            <el-table-column prop="charging" label="实际重量（kg）">
              <template v-slot="scope">
                {{
                  scope.row.charging == "weight"
                    ? scope.row.total_weight
                    : (scope.row.total_weight + "（不计费）")
                }}
              </template>
            </el-table-column>

            <el-table-column prop="charging" label="比重重系数">
              <template v-slot="scope">
                {{ scope.row.quotation_proportion }}
              </template>
            </el-table-column>

            <el-table-column prop="charging" label="比重体积">
              <template v-slot="scope">
                {{
                  scope.row.charging == "volume"
                    ? scope.row.proportion_weight
                    :  (scope.row.proportion_weight + "（不计费）")
                }}
              </template>
            </el-table-column>
            <el-table-column prop="charging" label="实际体积（m³）">
              <template v-slot="scope">
                {{
                  scope.row.charging == "volume"
                    ? scope.row.total_volume
                    : (scope.row.total_volume + "（不计费）")
                }}
              </template>
            </el-table-column>
            <el-table-column prop="charging" label="实际件数">
              <template v-slot="scope">
                {{
                  scope.row.charging == "piece"
                    ? scope.row.total_piece
                    :  (scope.row.total_piece + "（不计费）")
                }}
              </template>
            </el-table-column>
            <el-table-column prop="charging" label="计费重量">
              <template v-slot="scope">
                {{
                  scope.row.charging == "weight"
                    ? scope.row.cost_weight
                    :   (scope.row.cost_weight + "（不计费）")
                }}
              </template>
            </el-table-column>
            <el-table-column prop="charging" label="计费体积">
              <template v-slot="scope">
                {{
                  scope.row.charging == "volume"
                    ? scope.row.cost_volume
                    :    (scope.row.cost_volume + "（不计费）")
                }}
              </template>
            </el-table-column>
            <el-table-column prop="charging" label="计费件数">
              <template v-slot="scope">
                {{
                  scope.row.charging == "piece"
                    ? scope.row.total_piece
                     :(scope.row.total_piece + "（不计费）")
                }}
              </template>
            </el-table-column>
            <el-table-column prop="charging" label="计费公式" min-width="200">
              <template v-slot="scope">
                {{ scope.row.cost_function }}
              </template>
            </el-table-column>
            <el-table-column prop="charging" label="运费">
              <template v-slot="scope">
                {{ scope.row.price }}
              </template>
            </el-table-column>
          </el-table>
        </div>
          </el-tab-pane>
       <el-tab-pane label="包含包裹" name="fourth">
        <div>
          <el-table :data="orderList"  class="table-box" v-if="!loading" >
            <el-table-column prop="order_no" label="订单号"></el-table-column>
            <el-table-column
              prop="order_logistic_no"
              label="快递单号"
            ></el-table-column>
            <el-table-column prop="order_transport_type" label="包裹类型">
              <template v-slot="scope">
                {{ getLable(typeOptions, scope.row.order_transport_type) }}
              </template>
            </el-table-column>
            <el-table-column prop="order_piece" label="件数"></el-table-column>
            <el-table-column
              prop="order_good_length"
              label="包裹尺寸(cm)"
            >
            <template v-slot="scope">
                {{scope.row.order_good_length}} * {{scope.row.order_good_width}} * {{scope.row.order_good_height }}
              </template>
            </el-table-column>
           
            <el-table-column
              prop="order_good_weight"
              label="体积(m³)"
            >
              <template v-slot="scope">
                {{ Number(scope.row.order_good_width * scope.row.order_good_height * scope.row.order_good_length * scope.row.order_piece/1000000).toFixed(3) }}
              </template>
            </el-table-column>
            <el-table-column
              prop="order_good_weight"
              label="包裹重量(kg)"
            >
              
            </el-table-column>
            <el-table-column
              prop="order_good_weight"
              label="总重量(kg)"
            >
              <template v-slot="scope">
                {{ scope.row.order_good_weight * scope.row.order_piece }}
              </template>
            </el-table-column>
            <el-table-column prop="manage_account" label="入库员">
              <template v-slot="scope">
                {{ scope.row.manage_account }}（ {{ scope.row.order_inbound_manage }}）
              </template>
            </el-table-column>
            <el-table-column prop="order_inbound_time" label="入库时间">
              <template v-slot="scope">
                {{ moment(Number(scope.row.order_inbound_time) * 1000).format("YYYY-MM-DD HH:mm")  }}
              </template>
            </el-table-column>
             <el-table-column prop="order_inbound_images" label="入库图片">
              <template v-slot="scope">
                 <template  v-if="scope.row.order_inbound_images?.length">
                  <el-image
                   @click="handleShowImage(scope.row.order_inbound_images)"
                  :teleported="true"
                  v-for="(item, index) in scope.row.order_inbound_images"
                  :key="index"
                    style="width: 100px; height: 100px"
                    :src="$imageBaseUrl + item"
                    :zoom-rate="1.2"
                    :max-scale="7"
                    :min-scale="0.2"
                    fit="cover"
                  
                  />
                </template>
              </template>
            </el-table-column>
          </el-table>
        </div>
      </el-tab-pane>
     
      <el-tab-pane label="收货信息" name="second">
        <el-descriptions :column="2" size="defalut" border>
          <el-descriptions-item label="收货人姓名">
            {{ addressData.address_name }}
          </el-descriptions-item>
          <el-descriptions-item label="收货人手机">
            {{ addressData.address_phone }}
          </el-descriptions-item>
          <el-descriptions-item label="收货地区">
            {{ addressData.address_country }}
          </el-descriptions-item>
          <el-descriptions-item label="收货邮编">
            {{ addressData.address_code }}
          </el-descriptions-item>
          <el-descriptions-item label="收货地址">
            {{ addressData.address_detail }}
          </el-descriptions-item>
        </el-descriptions>
      </el-tab-pane>

 
      <el-tab-pane label="轨迹查询" name="five"> 

        <el-timeline style="max-width: 200px; padding:20px;    text-align: left;">
          <el-timeline-item
            v-for="(activity, index) in trackData"
            :key="index"
            :timestamp="activity.track_time"
          >
            {{ activity.track_type_dim_text }}
          </el-timeline-item>
        </el-timeline>

      </el-tab-pane>
      <el-tab-pane label="操作日志" name="six"> 
         <el-table
            :data="trackData"
            border
            class="table-box"
            v-if="!loading"
          >
            <el-table-column prop="index" label="序号" width="80">
              <template v-slot="scope">
                {{ scope.$index + 1 }}
              </template>
            </el-table-column>
            <el-table-column prop="track_time" label="时间">
            </el-table-column>
            <el-table-column prop="charging" label="操作员">
              <template v-slot="scope">
                {{ scope.row.manage_account_model_text }}
              </template>
            </el-table-column>
             <el-table-column prop="track_type_dim_text" label="操作内容">
              <template v-slot="scope">
                {{ scope.row.track_type_dim_text }}
              </template>
            </el-table-column>
         </el-table>
      </el-tab-pane>
       
      <el-tab-pane label="计费方案" name="first">
        <el-form
          :model="form"
          :rules="rules"
          label-width="160px"
          ref="forms"
          :disabled="true"
          v-if="!loading"
        >
          <el-form-item prop="quotation_name" label="方案名称">
            <ekInput v-model="form.quotation_name" />
          </el-form-item>
          <el-form-item prop="quotation_throwing_weight" label="抛重系数">
            <ekInput v-model="form.quotation_throwing_weight" />
          </el-form-item>
          <el-form-item prop="quotation_min" label="最低消费">
            <ekInput v-model="form.quotation_min" />
          </el-form-item>
          <el-form-item prop="quotation_proportion" label="比重比率">
            <ekInput v-model="form.quotation_proportion" />
          </el-form-item>
          <el-form-item prop="quotation_weight_price" label="首重价格">
            <ekInput v-model="form.quotation_weight_price" />
          </el-form-item>

          <el-form-item prop="quotation_plan" label="计费方案">
            <ekRadio
              v-model="form.quotation_plan"
              :options="quotationOptions"
            />
          </el-form-item>

          <el-form-item
            prop="quotation_plan_ratio"
            label="计费系数"
            v-if="form.quotation_plan == 2"
          >
            <ekInput v-model="form.quotation_plan_ratio" />
          </el-form-item>
          <el-form-item prop="quotation_transport" label="运输方式">
            <ekCheckbox
              v-model="form.quotation_transport"
              :options="modeOptions"
            />
          </el-form-item>
          <el-form-item prop="quotation_type" label="货品类型">
            <ekCheckbox v-model="form.quotation_type" :options="typeOptions" />
          </el-form-item>
          <el-form-item prop="quotation_price" label="计费组合">
            <el-table :data="form.quotation_price" border class="table-box">
              <el-table-column prop="transport_mode" label="运输方式">
                <template v-slot="scope">
                  {{ getLable(modeOptions, scope.row.transport_mode) }}
                </template>
              </el-table-column>
              <el-table-column prop="transport_type" label="运输类型">
                <template v-slot="scope">
                  {{ getLable(typeOptions, scope.row.transport_type) }}
                </template>
              </el-table-column>
              <!-- <el-table-column prop="transport_first_price" label="首重价格">
                <template v-slot="scope">
                  <el-input
                    v-model.number="scope.row.transport_first_price"
                    placeholder="输入首重价格"
                  ></el-input>
                </template>
              </el-table-column> -->
              <el-table-column prop="transport_price" label="续重价格">
                <template v-slot="scope">
                  <el-input
                    v-model.number="scope.row.transport_price"
                    placeholder="输入价格"
                  ></el-input>
                </template>
              </el-table-column>
              <el-table-column prop="transport_cube_price" label="立方价格">
                <template v-slot="scope">
                  <el-input
                    v-model.number="scope.row.transport_cube_price"
                    placeholder="输入价格"
                  ></el-input>
                </template>
              </el-table-column>
              <el-table-column prop="transport_piece_price" label="按件价格">
                <template v-slot="scope">
                  <el-input
                    v-model.number="scope.row.transport_piece_price"
                    placeholder="输入价格"
                  ></el-input>
                </template>
              </el-table-column>
            </el-table>
          </el-form-item>
        </el-form>
      </el-tab-pane>
      <el-tab-pane label="其他费用" name="nine">
        <div class="f-20 f-bold" style="margin-bottom: 10px;text-align: right;color: #999;">总附加费用：<span style="color: #f56c6c;">{{ itemPrice }}元</span></div>
        <el-table :data="baseData.transfer_items" border class="table-box">
          <el-table-column prop="name" label="附加费用名称">
            <template v-slot="scope">
              {{ scope.row.name }}
            </template>
          </el-table-column>
          <el-table-column prop="price" label="附加费用金额（元）">
            <template v-slot="scope">
              {{ scope.row.price }}
            </template>
          </el-table-column>
          <el-table-column prop="type" label="附加费用类型">
            <template v-slot="scope">
              {{ scope.row.type == 1 ? '可选费用':'必要费用' }}
            </template>
          </el-table-column>
          <el-table-column prop="need" label="是否需要">
            <template v-slot="scope">
              <el-button type="success" link size="small" v-if="scope.row.need == 1">是</el-button>
              <el-button type="danger" link size="small" v-else>否</el-button>
            </template>
          </el-table-column>
        </el-table>
      </el-tab-pane>

    </el-tabs>
    <div style="height:200px;"></div>
    <div class="audit" :class="{ 'is-open': menuOpened }" v-if="!loading && baseData.pay_state == '3'">
      <div class="f-20 f-bold">审核信息</div>
      <div class="flex mt-15">
        <div>
          <div class="flex">
            转账截图：
            <el-image
              style="width: 100px; height: 100px"
              :src="$imageBaseUrl + baseData.transfer_audit_image[0]"
              :zoom-rate="1.2"
              :max-scale="7"
              :min-scale="0.2"
              :preview-src-list="[
                $imageBaseUrl + baseData.transfer_audit_image[0],
              ]"
              :initial-index="4"
              fit="cover"
              v-if="baseData.transfer_audit_image?.length"
            />
          </div>
        </div>

        <div class="ml-50">
          <div class="flex items-center">
            订单金额：<span
              class="f-20"
              style="display: inline-block; color: #f56c6c; font-weight: bold"
              >￥{{ baseData.transfer_price }}</span
            >
          </div>
          <div class="flex items-center mt-8" v-if="baseData.pay_state == '2'">
            审核情况：
            <ekRadio
              v-model="auditForm.transfer_pass"
              :options="[
                {
                  value: 'pass',
                  label: '通过',
                },
                {
                  value: 'unpass',
                  label: '驳回',
                },
              ]"
              :disabled="true"
            />
          </div>
          <div class="flex items-center mt-8">
            审核意见：
            <ekInput v-model="auditForm.transfer_audit_message" />
          </div>
          <div v-if="baseData.pay_state != '2'" class="mt-8">
            <el-button @click="unAgree()" type="danger"> 驳回 </el-button>
            <el-button @click="agree()" type="success"> 同意 </el-button>
          </div>
        </div>
      </div>
    </div>
    <el-image-viewer
        v-if="showPreview"
        :url-list="imageList"
        show-progress
        :initial-index="0"
        @close="showPreview = false"
      />
  </div>
</template>

<script setup>
import {
  watch,
  getCurrentInstance,
  computed,
  reactive,
  ref,
  defineEmits,
  onMounted,
} from "vue";
import { apis } from "./data.js";
import ekDialog from "@/components/business/ekDialog/index.vue";
import ekInput from "@/components/form/ekInput/index.vue";
import ekSelect from "@/components/form/ekSelect/index.vue";
import ekTableSelect from "@/components/form/ekTableSelect/index.vue";
import ekSelectModel from "@/components/form/ekSelectModel/index.vue";
import ekTextarea from "@/components/form/ekTextarea/index.vue";
import ekCheckbox from "@/components/form/ekCheckbox/index.vue";
import ekRadio from "@/components/form/ekRadio/index.vue";
import { objectAssignment, getLable, transformArray } from "@/utils/common.js";
import { getDimensionByCode } from "@/utils/sys.js";
import { useRoute } from "vue-router";
import { useStore } from "vuex";
import moment from "moment";

// store 获取
const store = useStore();
// 菜单是否开启
const menuOpened = computed(() => {
  return store.getters["layout/getMenuOpened"];
});
const itemPrice = computed(() => {
  let price = 0;
  if(baseData.value.transfer_items?.length){
    for(let item of baseData.value.transfer_items){
      if(item.need == 1){
        price += Number(item.price);
      }
    }
  }
  return price.toFixed(2);
})

const route = useRoute();
const {
  appContext: {
    config: { globalProperties },
  },
} = getCurrentInstance();
const { $storage, $http, $ekLoading, $ekMessage, $imageBaseUrl } =
  globalProperties;

const emit = defineEmits(["update:visiable", "submit"]);
const transfer_no = route.query.transfer_no ||  route.params.transfer_no;

let auditForm = ref({
  transfer_audit_message: "",
  transfer_pass: "pass",
});

const showPreview = ref(false)
const imageList = ref([])
const handleShowImage = (list) => {
  showPreview.value = true;
  let arr = [];
  for(let item of list){
    arr.push($imageBaseUrl + item);
  }
  console.log(arr,'arr')
  imageList.value = arr 
}
const charging = { volume: "按体积", weight: "按重量", piece: "按件数" };
const loading = ref(false);
let forms = ref(null);
let form = ref(null);
const activeName = ref("third");
const initForm = () => {
  form.value = {
    quotation_name: "",
    quotation_throwing_weight: "",
    quotation_proportion: "",
    quotation_min: "",
    quotation_transport: [],
    quotation_type: [],
    quotation_price: [],
    quotation_plan: "",
    quotation_plan_ratio: "",
    quotation_weight_price: "",
    transfer_no: transfer_no,
  };
};
initForm();
let rules = reactive({
  quotation_name: [{ required: true, message: "请输入名称", trigger: "blur" }],
  quotation_plan: [
    { required: true, message: "请输入计费方案", trigger: "blur" },
  ],
  quotation_transport: [
    { required: true, message: "请选择运输方式", trigger: "blur" },
  ],
  quotation_type: [
    { required: true, message: "请选择货品类型", trigger: "blur" },
  ],
});
const detail = ref({});
const baseData = ref({});
const orderList = ref([]);
const addressData = ref([]);
const modeOptions = ref([]);
const typeOptions = ref([]);
const costData = ref({});
const payData = ref({});
const trackData = ref([])
const userData= ref({});
const handleClick = (name) => {
  activeName.value = name;
};
const getSummaries = () => {
  return [
    "合计",
    "-",
    "-",
    "-",
    "-",
    "-",
    "-",
    "-",
    "-",
    costData.value.total_weight_cost
      ? costData.value.total_weight_cost
      : (costData.value.total_weight_cost + "（不计费）"),
    costData.value.total_volume_cost
      ? costData.value.total_volume_cost
      : (costData.value.total_volume_cost + "（不计费）"),
    costData.total_piece ? costData.value.total_piece :  (costData.value.total_piece + "（不计费）"),
    "-",
    "￥" + baseData.value.transfer_price,
  ];
};
const getCost = (item) => {
  if (item.charging == "volume") {
    // 比重
    if (item.proportion_weight > item.total_volume) {
      return "比重（体积重和实重取大值）";
    } else {
      return "实体积";
    }
  }
  if (item.charging == "weight") {
    // 全抛
    if (item.throwing_weight > item.total_weight) {
      return "全抛（体积重和实重取大值）";
    } else {
      return "实重";
    }
  }
  if (item.charging == "piece") {
    return "按件收费";
  }
};
// 初始化表单
async function init() {
  loading.value = true;
  // 详情或者编辑
  $http
    .get(apis.detail, {
      params: {
        transfer_no: transfer_no || null,
      },
    })
    .then((res) => {
      if (Object.keys(res.data).length) {
        form.value = {
          ...res.data.quotation,
        };

        typeOptions.value = res.data.type;
        modeOptions.value = res.data.mode;

        addressData.value = res.data.address_data;
        baseData.value = res.data.base_data;
        orderList.value = res.data.cost_data.order_list;
        costData.value = res.data.cost_data;
        form.value = res.data.cost_data.quotation_config;
        payData.value = res.data.pay_data;
        trackData.value = res.data.track;
        userData.value= res.data.user_data;
        objectAssignment(form.value, res.data);
        console.log(typeOptions, "typeOptions");
      }
      loading.value = false;
    });
}

const agree = () => {
  $http
    .request({
      url: apis.audit,
      method: "PUT",
      data: {
        ...auditForm.value,
        transfer_pass: "pass",
        transfer_no: transfer_no,
      },
    })
    .then((res) => {
      $ekMessage.success(res.message);
      init()
    })
    .catch((err) => {});
};
const unAgree = () => {
  $http
    .request({
      url: apis.audit,
      method: "PUT",
      data: {
        ...auditForm.value,
        transfer_pass: "unpass",
        transfer_no: transfer_no,
      },
    })
    .then((res) => {
      $ekMessage.success(res.message);
       init()
    })
    .catch((err) => {});
};
const quotationOptions = ref([]);
const transferStateOptions = ref([]);
const payStateOptions = ref([]);
const dispatchStatus = ref([]);
onMounted(async () => {
  init();
  quotationOptions.value = await getDimensionByCode("DIM_QUOTATION_STATE");
  transferStateOptions.value = await getDimensionByCode("DIM_ORDER_STATE");
  payStateOptions.value = await getDimensionByCode("DIM_TRANSFER_PAY_STATE");
  dispatchStatus.value = await getDimensionByCode("DIM_TYPE_DELIVERY");
});
</script>

<style scoped lang="scss">
$sidebar-width: 64px;
// 侧边栏展开宽度
$sidebar-openwidth: 260px;
.audit {
  background-color: rgb(255, 255, 255);
  padding: 15px 30px;
  text-align: left;
  position: fixed;
  z-index: 99;
  bottom: 0;
  left: $sidebar-width;
  width: calc(100% - $sidebar-width);
  box-shadow: var(--base-box-shadow-dark);
  &.is-open {
    left:$sidebar-openwidth;
     width: calc(100% - $sidebar-openwidth);
  }
}
</style>
